﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Compilation;
using System.Web.Routing;
using System.Web.UI;

namespace Novapangeia_net.Aplicacao
{
    public class HandlerRoteamentoPagina : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            string pageName
                = requestContext.RouteData.GetRequiredString("Parameter");

            pageName =
                pageName.ToLower() == "home" ? "default" : pageName;

            string virtualPath
                = string.Format("~/Layout/{0}.aspx", pageName);

            return (Page)BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page));
        }
    }
}
